package pack04_covid_merge;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @author lilulu
 * @date 2023/2/11 13:16
 */
public class CovidCountMapper extends Mapper<LongWritable, Text,Text,CovidCountBean> {
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String[] split = value.toString().split(",");
        if (split.length < 6) {
            return;
        }
        String k2 = split[2];
        CovidCountBean covidCountBean = new CovidCountBean();
        covidCountBean.setCases(Integer.parseInt(split[4]));
        covidCountBean.setDeaths(Integer.parseInt(split[5]));
        context.write(new Text(k2),covidCountBean);
    }
}
